/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package TableView;

import data.Deptinterdependency;
import data.Deptinterdependency;
import java.util.ArrayList;
import java.util.List;
import javax.swing.table.AbstractTableModel;

/**
 *
 * @author ChiHieu
 */
public class DeptinterdependencyTable extends AbstractTableModel {

	private List<Deptinterdependency> dpms;

	public DeptinterdependencyTable() {
		this(new ArrayList<Deptinterdependency>());
	}

	public DeptinterdependencyTable(List<Deptinterdependency> dpms) {
		this.dpms = dpms;
	}

	@Override
	public int getRowCount() {
		return dpms.size();
	}

	@Override
	public int getColumnCount() {
		return 4;
	}

	@Override
	public Object getValueAt(int rowIndex, int columnIndex) {
		Object value = null;
		Deptinterdependency dpm = dpms.get(rowIndex);
		switch (columnIndex) {
			
			case 0: {
				value = dpm.getId();
				break;
			}
			case 1: {
				value = dpm.getUpdeptno();
				break;
			}
			case 2: {
				value = dpm.getDepartments().getDeptname();
				break;
			}
			case 3: {
				value = dpm.getDndeptno();
				break;
			}
		}
		return value;
	}

	@Override
	public String getColumnName(int column) {
		String value = "";
		switch (column) {
			case 0: {
				value = "Id";
				break;
			}
			case 1: {
				value = "NOUPPER";
				break;
			}
			case 2: {
				value = "DEPNAME";
				break;
			}
			case 3: {
				value = "NODN";
				break;
			}
		}
		return value;
	}
}
